package com.sense.kukoo.common.wiget.adapter.provider;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.sense.kukoo.common.wiget.adapter.viewholder.BaseViewHolder;


public abstract class MultiItemProvider<T> {
    /**
     * 组件的标识符
     * @return
     */
    public abstract int getItemType();

    /**
     * 组件的布局id
     * @return
     */
    public abstract int getItemLayoutId();

    /**
     * 具体业务逻辑在这里写 例如mvvm的数据绑定，以及传统的setText 等方法
     * @param viewHolder
     * @param item
     */
    public abstract void onBindViewHolder(BaseViewHolder viewHolder, T item);
    public void onViewAttachedToWindow(BaseViewHolder holder) {
    }

    public void onViewDetachedFromWindow(BaseViewHolder holder) {
    }

    public BaseViewHolder onCreateViewHolder(ViewGroup parent,int viewType){
        ViewGroup viewGroup = (ViewGroup) LayoutInflater.from(parent.getContext()).inflate(getItemLayoutId(), parent, false);
        return new BaseViewHolder(viewGroup);
    }
}
